package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.*;
import com.hualude.roadsign.service.FeedbackService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by xu-jiaHui on 2017/4/10.
 */
@Controller
@RequestMapping("/rds_feedback")
public class FeedBackController {

    @Resource
    private FeedbackService feedbackService;

    @RequestMapping(value = "/addFeedBack")
    @ResponseBody
    public JsonMsgDto addFeedBack(FeedbackDto feedbackDto) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setIsSuccess(true);
            jsonMsgDto.setJsonData(feedbackService.addFeedBack(feedbackDto));
        } catch (Exception e) {
            jsonMsgDto.setIsSuccess(false);
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getFeedBack4Dt")
    @ResponseBody
    public DTResponseDto getFeedBack4Dt(DTRequestDto dtRequestDto) throws Exception {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = feedbackService.getFeedBack4Dt(dtRequestDto);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping(value = "/getAboutInfo")
    @ResponseBody
    public JsonMsgDto getAboutInfo(Integer infoId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setIsSuccess(true);
            jsonMsgDto.setJsonData(feedbackService.getAboutInfo(infoId));
        } catch (Exception e) {
            jsonMsgDto.setIsSuccess(false);
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/updataAboutInfo")
    @ResponseBody
    public JsonMsgDto updataAboutInfo(Integer infoId, String aboutTele, String aboutFax, String aboutMail, String aboutWebsite) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setIsSuccess(true);
            jsonMsgDto.setJsonData(feedbackService.updataAboutInfo(infoId, aboutTele, aboutFax, aboutMail, aboutWebsite));
        } catch (Exception e) {
            jsonMsgDto.setIsSuccess(false);
            e.printStackTrace();
        }
        return jsonMsgDto;
    }
}
